package com.gangwangchina.android.readsms.ui;



import com.gangwangchina.android.readsms.R;

import android.content.Context;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;

public class Settings extends PreferenceActivity {

	private static final String OPT_READ = "autoread";
	private static final String OPT_READRECV = "readrecv";
	private static final String OPT_DOWNSTOPREAD = "downstopread";
	private static final String OPT_AUTOSTART = "autostart";
	private static final String OPT_READCOUNT = "readcount";
	
	
	
	private static final boolean OPT_READ_DEF = true;
	private static final boolean OPT_READRECV_DEF = true;
	private static final boolean OPT_DOWNSTOPREAD_DEF = true;
	private static final boolean OPT_AUTOSTART_DEF = true;
	private static final int 	 OPT_READCOUNT_DEF = 1;
	
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		
		addPreferencesFromResource(R.xml.settings);
	}
	
	
	public static boolean getAutoRead(Context context)
	{
		return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(OPT_READ, OPT_READ_DEF);
	}
	
	public static boolean getReadRecv(Context context)
	{
		return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(OPT_READRECV, OPT_READRECV_DEF);
	}
	
	public static boolean getDownAStopRead(Context context)
	{
		return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(OPT_DOWNSTOPREAD, OPT_DOWNSTOPREAD_DEF);
	}
	
	public static boolean getAutoStart(Context context)
	{
		return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(OPT_AUTOSTART, OPT_DOWNSTOPREAD_DEF);
	}
	
	public static int getReadCount(Context context)
	{
		try {
			return PreferenceManager.getDefaultSharedPreferences(context).getInt(OPT_READCOUNT, OPT_READCOUNT_DEF);
		} catch (Exception e) {
			return OPT_READCOUNT_DEF;
		}
		
	}
	
}
